package com.example.home.youthstation;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.bumptech.glide.Glide;
import com.example.home.R;
import com.example.home.tool.OKHttpTool;

import static com.example.home.tool.StaticActi.ip;

public class StationDetailsActivity extends AppCompatActivity {

    private String dataBeanID;
    private TextView yizhan_introduce;
    private TextView yizhan_name;
    private ImageView yizhan_img;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_station_details);
        Intent intent = getIntent();
        dataBeanID = intent.getStringExtra("DataBeanId");

        initview();
        sendbena();
    }

    private void sendbena() {
        OKHttpTool.doNetRequest("prod-api/api/youth-inn/talent-policy-area/"+dataBeanID,
                OKHttpTool.GET,
                HostelBean.class,
                new OKHttpTool.NetCallback() {
                    @Override
                    public void onSuccess(Object obj) {
                        HostelBean hostelBean = (HostelBean) obj;
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                Glide.with(StationDetailsActivity.this).load(ip+hostelBean.getData().getImgUrl()).into(yizhan_img);
                                yizhan_name.setText(hostelBean.getData().getName());
                                yizhan_introduce.setText(hostelBean.getData().getIntroduce());
                            }
                        });
                    }

                    @Override
                    public void onFailure(String msg) {
                        Log.v("xhf","访问失败");
                    }
                }
        );
    }

    private void initview() {
        yizhan_img = findViewById(R.id.yizhan_img);
        yizhan_name = findViewById(R.id.yizhan_name);
        yizhan_introduce = findViewById(R.id.yizhan_introduce);
    }
}